﻿using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using WpfAdvControls;

namespace TfsComLib.TfsConnection.View
{
    /// <summary>
    ///     Interaction logic for TfsWorkspaceProperties.xaml
    /// </summary>
    public partial class TfsWorkspaceProperties : UserControl
    {
        private TfsWorkspaceData workspaceData;

        public TfsWorkspaceProperties()
        {
            InitializeComponent();
        }

        public TfsWorkspaceProperties(TfsWorkspaceData workspaceData)
        {
            InitializeComponent();
            Bind(workspaceData);
        }

        public void Bind(TfsWorkspaceData workspaceData)
        {
            //IsEnabled="{Binding ElementName=rbDedicated, Path=IsChecked}"
            this.workspaceData = workspaceData;
            CommonUI.BindProperty("Workspaces", workspaces, ItemsControl.ItemsSourceProperty, workspaceData);
            CommonUI.BindProperty("Workspace", workspaces, Selector.SelectedValueProperty, workspaceData);
            //CommonUI.BindProperty("WorkspaceName", workspaces, ComboBox.TextProperty, workspaceData);
            CommonUI.BindProperty("IsTemporary", rbTemporary, ToggleButton.IsCheckedProperty, workspaceData);
            CommonUI.BindProperty("IsTemporary", rbDedicated, ToggleButton.IsCheckedProperty, workspaceData,
                new NegativeBoolConverter());
        }
    }
}